package com.example.big_event.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.FieldFill;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("user")
public class User {

    @JsonIgnore
    @NotNull
    private Integer id; //主键ID
    private String username; //用户名

    @JsonIgnore
    // 将用户转化为json字符串的时候会使密码不显示
    private String password; //密码

    private String nickname; //昵称
    @Size(min = 1, max = 2, message = "密码长度必须在1-2个字符之间")
    private String email; //邮箱
    private String userPic; //用户头像地址


    @JsonIgnore
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime; //创建时间

    @JsonIgnore
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime; //更新时间

    public User(String username, String password){
        this.username = username;
        this.password = password;
    }
}
